package com.comcast.core.eeg.eventpublication.service.ws;

// Import the standard JWS annotation interfaces

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import weblogic.jws.security.RolesAllowed; 
import weblogic.jws.security.SecurityRole; 
import weblogic.jws.WLHttpTransport;

import com.comcast.core.eeg.types.Result;

//wl10.3.1 stuff
//import javax.xml.ws.WebServiceContext;
//import javax.annotation.Resource;

@WebService(name = "EventPublicationService", targetNamespace = "http://xml.comcast.com/eeg/publication/services")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)

@WLHttpTransport(contextPath="publication", serviceUri="EventPublicationService", portName="EventPublicationServicePort")
@RolesAllowed (  { 
    @SecurityRole (role="EEG_PUBLISHER") 
} ) 

/**
 * Entry point for generating the WS
 *
 */
public class EventPublication {
    
    private EventPublicationService service;

    //@Resource
    //private WebServiceContext ctx;

    //dynamic security check - for JAX-WS - @RolesAllowed() annotation not work - 10.3.1
    //context.getUserPrincipal()
    //context.isUserInRole

    public EventPublication() {
        service = new EventPublicationServiceImpl();
    }


    @WebMethod()
    @WebResult(name = "publishResult", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
    public Result publish(
            @WebParam(name = "participant", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
            String participant,
            @WebParam(name = "xmlEvent", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
            XmlEvent xmlEvent) {
        return service.publish(participant, xmlEvent);
    }

    @WebMethod()
    @WebResult(name = "batchPublishResult", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
    public Result batchPublish(
            @WebParam(name = "participant", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
            String participant,
            @WebParam(name = "xmlEvents", targetNamespace = "http://xml.comcast.com/eeg/publication/types")
            XmlEvent[] xmlEvents) {
        return service.batchPublish(participant, xmlEvents);
    }

}
